package com.ctshk.sapp.finance.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.finance.dto.special.SpecialCollectionDetailDTO;
import com.ctshk.rpc.finance.dto.special.SpecialCollectionListDTO;
import com.ctshk.rpc.finance.req.special.SpecialCollectionAddReq;
import com.ctshk.rpc.finance.req.special.SpecialCollectionApprovalReq;
import com.ctshk.rpc.finance.req.special.SpecialCollectionIdReq;
import com.ctshk.rpc.finance.req.special.SpecialCollectionListReq;
import com.ctshk.rpc.finance.service.IFinanceSpecialCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 财务特殊收款 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-05
 */
@RestController
@Api(value = "特殊收款", tags = "特殊收款")
@RequestMapping("/finance-special-collection")
public class FinanceSpecialCollectionController extends BaseController {

    @DubboReference
    private IFinanceSpecialCollectionService specialCollectionService;


    @ApiOperation(value = "列表", notes = "列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "特殊收款-列表", operDesc = "特殊收款-列表")
    @PostMapping("/list")
    public Result<PageResponse<SpecialCollectionListDTO>> list(@RequestBody SpecialCollectionListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return specialCollectionService.list(req);
    }

    @ApiOperation(value = "新增", notes = "新增（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.ADD, operTitle = "特殊收款-新增", operDesc = "特殊收款-新增")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid SpecialCollectionAddReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return specialCollectionService.add(req);
    }

    @ApiOperation(value = "详情", notes = "详情（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "特殊收款-详情", operDesc = "特殊收款-详情")
    @PostMapping("/detail")
    public Result<SpecialCollectionDetailDTO> detail(@RequestBody @Valid SpecialCollectionIdReq req) {
        return specialCollectionService.detail(req);
    }

    @ApiOperation(value = "删除", notes = "删除（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.DELETE, operTitle = "特殊收款-删除", operDesc = "特殊收款-删除")
    @PostMapping("/del")
    public Result del(@RequestBody @Valid SpecialCollectionIdReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return specialCollectionService.del(req);
    }

    @ApiOperation(value = "提交审批", notes = "提交审批（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.UPDATE, operTitle = "特殊收款-提交审批", operDesc = "特殊收款-提交审批")
    @PostMapping("/to-approval")
    public Result toApproval(@RequestBody SpecialCollectionIdReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return specialCollectionService.toApproval(req);
    }

    @ApiOperation(value = "审批", notes = "审批（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.UPDATE, operTitle = "特殊收款-审批", operDesc = "特殊收款-审批")
    @PostMapping("/approval")
    public Result approval(@RequestBody SpecialCollectionApprovalReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return specialCollectionService.approval(req);
    }

}
